<?php
$this->breadcrumbs = array(
    'Categorization' => array('/Admin/term/index'),
    'Type' => array('index'),
    'Manage',
);

$this->menu = array(
    array('label' => 'Create Vocabulary', 'url' => array('create')),
);

$script = "
\$('.grid-view .status-column a').live('click', function(){
    $.get(\$(this).attr('href'), function(){
        $.fn.yiiGridView.update('vocabulary-grid');
    });
    return false;
});
";
$cs = Yii::app()->clientScript;
$cs->registerScript(__CLASS__ . '#ChangeStatus', $script, CClientScript::POS_READY);
?>

<h1>Manage Type</h1>

<?php $grid = $this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'vocabulary-grid',
    'dataProvider' => $model->search(),
    'filter' => $model,
    'selectableRows' => 2,
    'selectionChanged' => "updateSelectors",
    'columns' => array(
        array(
            'class' => 'CCheckBoxColumn',
            'value' => '$data->id',
            'htmlOptions' => array('width' => '3%'),
        ),
        /*'id',*/
        'name',
        'alias',
        array(
            'name' => 'module',
            'value' => '$data->module',
            'filter' => $modules,
        ),
        array(
            'name' => 'status',
            'type' => 'raw',
            'value' => 'CHtml::link($data->stateText, array("/Core/Service/ajax", "SID"=>"Admin.Vocabulary.changeState", "ids[]"=>$data->id, "value"=>$data->state ? 0 : 1), array("class"=>($data->state ? "active" : "")))',
            'filter' => false,
            'sortable' => false,
            'htmlOptions' => array(
                'class' => 'status-column'
            )
        ),
        array(
            'class' => 'CButtonColumn',
            'template' => '{update} {delete}',
        ),
    ),
));

if ($grid->dataProvider->ItemCount) {
    $this->menu[] = array('label' => 'Delete selected items', 'url' => $this->createUrl('delete'), 'linkOptions' => array('onclick' => 'return multipleDelete("vocabulary-grid",this.href)'));
}
Yii::app()->clientScript->registerScriptFile(Yii::app()->core->AssetUrl . '/scripts/gridview.js', CClientScript::POS_BEGIN);
?>